package com.good.newlife.controller;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.alibaba.fastjson.JSON;
import com.good.newlife.entity.User;
import com.good.newlife.service.UserService;
/**
 * 
 * @author admin
 *
 */
@Controller
@RequestMapping("UserController")
public class UserController {
	Logger logger = LoggerFactory.getLogger(UserController.class);
	
	@Autowired
	private UserService userService;
	
	@RequestMapping("insert")
	public void insert(HttpServletRequest request, HttpServletResponse response,User user){
		logger.info(JSON.toJSONString(user));
		int in = userService.insert(user);
		if(in >0){
			logger.info("congratulations! add user success!!!");
			try {
				response.getWriter().print("<h1>success!!!!</h1>");
			} catch (IOException e) {
				e.printStackTrace();
			}  
		}
		
	}
	
}
